package com.yc.ioc.bean6_beanDefition;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.naming.spi.InitialContextFactory;

/**
 * @author zwei
 * @create 2024-07-29 10:10
 */
@Component
//@Scope("prototype")
@Scope("singleton")     //默认下，因为是单例  所以对象是eager实例化
public class Person implements InitializingBean, DisposableBean {
    public Person() {
        System.out.println("Person()构造");
    }
    @PostConstruct
    public void init(){
        System.out.println("Person的init方法");
    }
    @PreDestroy
    public void PreDestroy(){
        System.out.println("Person的PreDestroy方法");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("Person的afterPropertiesSet方法");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("Person的destroy方法");
    }
}
